﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace K.EnterpriseLibary
{
    public static class ResourcePublic
    {
        /// <summary>
        /// 获取资源字符串
        /// </summary>
        public static string GetResourceString(this Type resourceType, string resourceName)
        {
            System.Resources.ResourceManager resourceManager = new System.Resources.ResourceManager(resourceType);
            return resourceManager.GetString(resourceName);
        }

        /// <summary>
        /// 获取资源字符串
        /// </summary>
        public static object GetResourceObject(this Type resourceType, string resourceName)
        {
            System.Resources.ResourceManager resourceManager = new System.Resources.ResourceManager(resourceType);
            return resourceManager.GetObject(resourceName);
        }

        /// <summary>
        /// 获取资源字符串
        /// </summary>
        public static T GetResource<T>(this Type resourceType, string resourceName)
        {
            System.Resources.ResourceManager resourceManager = new System.Resources.ResourceManager(resourceType);
            return resourceManager.GetObject(resourceName).Cast<T>();
        }
    }
}
